const fs = require('fs');
const path = require('path');
let config = fs.readFileSync(path.join(__dirname,'./wdConfig.json'), 'utf8');
let res=null;
config = JSON.parse(config);
let TARGET_PATH=path.join(config.android.platform.buildPath,"jsb-default/frameworks/runtime-src/proj.android-studio");
wangdongFunc();
function wangdongFunc() {
    res = fs.readFileSync(path.join(TARGET_PATH,"app/build.gradle"), 'utf8');
    res = res.replace('com.wd.android',config.android.platform.packageName);
    res = res.replace('minifyEnabled true',"minifyEnabled false");
    res = res.replace('shrinkResources true',"shrinkResources false");
    res = res.replace('implementation fileTree(dir: \'libs\', include: [\'*.jar\',\'*.aar\'])',"");
    saveFunc("app/build.gradle",res);
    if(config.android.csjad.enable==true){
        res = fs.readFileSync(path.join(TARGET_PATH,"app/src/org/cocos2dx/javascript/AppActivity.java"), 'utf8');
        res = res.replace("SDKWrapper.getInstance().init(this);",config.android.platform.onCreate);
        saveFunc("app/src/org/cocos2dx/javascript/AppActivity.java",res);
    }
    console.log("wangdongFunc success");
}
function saveFunc(url,data) {
    fs.writeFileSync(path.join(TARGET_PATH, url), data, 'utf8');
}
